package com.idanchuang.support.etcache.remote.codec;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import org.springframework.lang.NonNull;

import java.nio.charset.StandardCharsets;

/**
 * keyConverter 的 fastjson 实现
 *
 * @author yjy
 * Created at 2021/12/21 9:51 下午
 */
public class FastjsonKeyConverter implements KeyConverter {

    @NonNull
    @Override
    public byte[] apply(@NonNull Object k) {
        String jsonString = JSON.toJSONString(k);
        return jsonString.getBytes(StandardCharsets.UTF_8);
    }

}
